import { getInfraFilePage, InfraFileQueryDTO, InfraFileVO } from '@/services/InfraFileService';
import { proxy } from '@@/exports';

interface InfraFileModelType {
  infraFile?: InfraFileVO;
  updateModalState: boolean;
  dataSource: InfraFileVO[];
}

const state = proxy<InfraFileModelType>({
  infraFile: undefined,
  updateModalState: false,
  dataSource: [],
});

const actions = {
  /**
   * 设置修改模态框状态
   * @param modalState 状态
   */
  setUpdateModalState(modalState: boolean) {
    state.updateModalState = modalState;
  },
  /**
   * 打开模态框
   * @param modalState
   * @param infraFile
   */
  openUpdateModal(modalState: boolean, infraFile?: InfraFileVO) {
    state.infraFile = infraFile;
    state.updateModalState = modalState;
  },
  async fetchDatasource(dto:InfraFileQueryDTO){
    return getInfraFilePage(dto)
  }
};

export const InfraFileModel = { state, actions };
